package Yangtz.Cs.Reader.Controller.Login;

import Yangtz.Cs.Entity.ReaderBean;
import Yangtz.Cs.Service.ReaderService;
import Yangtz.Cs.Utils.DataTransmissionUtil;
import Yangtz.Cs.Utils.SetEncodingUtil;
import net.sf.json.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/ResetPwdServlet")
public class ResetPwdServlet extends HttpServlet {

    private JSONObject jsonObject1=new JSONObject();

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置请求编码、响应方式和编码方式
        SetEncodingUtil.SetEncoding(request, response);

        //获取android发来的json格式数据
        jsonObject1= DataTransmissionUtil.gainJsonFromAndroid(request);

        //创建readerBean对象,并将其赋值为安卓端传来的数据
        ReaderBean readerBean=new ReaderBean();
        readerBean.setRdID(jsonObject1.optString("rdID"));
        readerBean.setRdPWd(jsonObject1.optString("rdPwd"));

        //ReaderService对象
        ReaderService rs=new ReaderService();
        rs.ResetPwd(readerBean,response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
